<div class="layuimini-container">
    <form id="app-form" class="layui-form layuimini-form">
        
        <div class="layui-form-item">
            <label class="layui-form-label">直播间号</label>
            <div class="layui-input-block">
                <select name="live_id" lay-filter="lives"  lay-verify="required" data-select="{:url('live.livegoods/lives')}" data-fields="id,live_no" data-value="{$row.id|default=''}">
                </select>
            </div>
        </div>
        <div class="layui-form-item" id="product">
            <label class="layui-form-label">可用商品</label>
            <div id="images">
                <img src="__STATIC__/admin/images/+.jpg" id="image" data-method="offset" style="border: 1px dashed black;" class="image">
            </div>
            <input type="hidden" id="goods_id" name="goods_id">
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">直播价格</label>
            <div class="layui-input-block">
                <input type="text" name="live_price" class="layui-input"  placeholder="请输入直播价格" value="">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">商品原价</label>
            <div class="layui-input-block">
                <input type="text" name="original_price" id="price" class="layui-input"  placeholder="请输入商品原价" value="">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">审核状态</label>
            <div class="layui-input-block">
                <input type="checkbox" checked="" value="1" name="status" lay-skin="switch" lay-filter="switchTest" lay-text="通过|不通过">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">是否显示</label>
            <div class="layui-input-block">
                <input type="checkbox" checked="" value="1" name="is_show" lay-skin="switch" lay-filter="switchTest" lay-text="显示|隐藏">
            </div>
        </div>
        <div class="hr-line"></div>
        <div class="layui-form-item text-center">
            <button type="submit" class="layui-btn layui-btn-normal layui-btn-sm" lay-submit>确认</button>
            <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">重置</button>
        </div>

    </form>
</div>
<script>
    layui.use(['jquery', 'form', 'upload', 'element', 'layer'], function () {
        var $ = layui.jquery;
        layer = layui.layer;

        var active = {
            offset: function(othis) {
                var type = othis.data('type')

                //添加商品
                layer.open({
                    type: 2
                    , area: ['800px','600px']
                    , offset: type //具体配置参考：http://www.layui.com/doc/modules/layer.html#offset
                    , id: 'layerDemo' + type //防止重复弹出
                    , content: "{:url('store.goods/selectGoods')}"
                    , btnAlign: 'c' //按钮居中
                    , shade: 0 //不显示遮罩
                    , yes: function (e) {
                        layer.closeAll();
                    },
                    end(){
                       var goods_id = $("#goods_id").val()
                        $.ajax({
                            url:"{:url('store.goods/goodsId')}",
                            data:{goods_id:goods_id},
                            success(res){
                                console.log(res)
                                $("#price").val(res.goods_price)
                            }
                        })
                    }
                });
            }
        }

        $('.image').on('click', function(){
            var othis = $(this), method = othis.data('method');
            active[method] ? active[method].call(this, othis) : '';
        });


    })

</script>
<style>
    .image {
        width: 60px;
        height: 60px;
    }
</style>